srs.muhaty2=function(data,x,y,n,mux){ data=as.name(data); x=x; y=y; n=n; mux=mux plot(x,y,main=data) r=sum(y)/sum(x); muhat.y=r*mux s2r=sum((y-r*x)^2)/(n-1) vhat.r=(1/mux^2)*(s2r/n) vhat.muhat.y=mux^2*vhat.r bound=2*sqrt(vhat.muhat.y) lower=muhat.y-bound; upper=muhat.y+bound cat("","\n","Results from SRS: Data =",data,"\n",'Estimation method = Ratio for mean y with unknown N','\n',"n =",n,"\n","Ratio r =",r ,"\n","Mu y =",muhat.y,"\n","Vhat mu.y =",vhat.muhat.y,"\n","Bound =",bound,"\n","Lower Bound =",lower,"Upper Bound =",upper,"\n","") results=list(r=r,data=data,n=n,vhat.r=vhat.r,bound=bound,lower=lower,upper=upper) } # to use the function with its call: # srs.muhaty2(data,x,y,n,mux) # data: name of dataset, in quotes # x: vector (data) # y: vector (data) # n: sample size # mux: value of mean of X